package com.message.tcp.ip.socket.configure.service;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.message.tcp.ip.socket.configure.dao.CardAccountDao;
import com.message.tcp.ip.socket.configure.entity.CardAccount;
@Service("cardAccountService")
public class CardAccountServiceImp implements CardAccountService {
	private static final Logger logger = Logger.getLogger(CardAccountServiceImp.class);
	@Autowired
	private CardAccountDao cardAccountDao;
	public void setCardAccountDao(CardAccountDao cardAccountDao){
		this.cardAccountDao = cardAccountDao;
	}
	@Override
	public void save(CardAccount cardAccount) {
		try {
			cardAccountDao.save(cardAccount);
		} catch (SQLException e) {
			logger.debug("Exception occured while try to save card account", e);
		}
	}

	@Override
	public void update(CardAccount cardAccount) {
		try {
			cardAccountDao.update(cardAccount);
		} catch (SQLException e) {
			logger.debug("Exception occur while try to update card account", e);
		}
	}

	@Override
	public CardAccount getCardAccount(CardAccount cardAcct) {
		try {
			return cardAccountDao.getCardAccount(cardAcct);
		} catch (SQLException e) {
			logger.debug("Exception occur while try to update card account", e);
			return null;
		}
	}
	
	@Override
	public String getCardNumber(){
		try {
			return cardAccountDao.getCardNumber();
		} catch (SQLException e) {
			logger.debug("Exception occured while try to get card number", e);
			return null;
		}
	}
	@Override
	public String getCardNumber(CardAccount cardAcct) {
		try {
			return cardAccountDao.getCardNumber(cardAcct);
		} catch (SQLException e) {
			logger.debug("Exception occured while try to get card number",e);
			return null;
		}
	}
	@Override
	public String getExpiryDate(String card) {
		try {
			return cardAccountDao.getExpiryDate(card);
		} catch (SQLException e) {
			logger.debug("Exception occur while try to get card expiry date", e);
			return null;
		}
	}
	@Override
	public String getCav(String card) {
		try {
			return cardAccountDao.getCav(card);
		} catch (SQLException e) {
			logger.debug("Exception occur while try to get card CAV", e);
			return null;
		}
	}
	@Override
	public String getAmtType(String card) {
		try {
			return cardAccountDao.getAmtType(card);
		} catch (SQLException e) {
			logger.debug("Exception occur while try to get amount type", e);
			return null;
		}
	}
	@Override
	public String getBalance(String card) {
		try {
			return cardAccountDao.getBalance(card);
		} catch (SQLException e) {
			logger.debug("Exception occured while try to get balance", e);
			return null;
		}
	}
	@Override
	public String getCurrency(String card) {
		try {
			return cardAccountDao.getCurrency(card);
		} catch (SQLException e) {
			logger.debug("Exception occured while try to get currency", e);
			return null;
		}
	}
	@Override
	public String getFlag(String card) {
		try {
			return cardAccountDao.getFlag(card);
		} catch (SQLException e) {
			logger.debug("Excepiton occured while try to get Flag", e);
			return null;
		}
	}
	@Override
	public List<CardAccount> getCardAccounts() {
		try {
			return cardAccountDao.getCardAccount();
		} catch (SQLException e) {
			logger.debug("Excepiton occured while try to get list", e);
			return null;
		}
	}

}
